package br.eng.eliseu.gwt.aconchego.camera.module;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.google.gwt.user.client.rpc.IsSerializable;

@Entity
@Table(name="USUARIO")
@SequenceGenerator(name="SEQ_USUARIO", sequenceName="SEQ_USUARIO")
@NamedQueries({
	@NamedQuery(name="usuario.selectTudo", query="select q from Usuario q "),
	@NamedQuery(name="usuario.selectPorEmail", query="select q from Usuario q where q.email = :email "),
	@NamedQuery(name="usuario.selectPorEmailSenha", query="select q from Usuario q where q.email = :email and q.senha = :senha "),
	
	@NamedQuery(name="usuario.deletePorEmailNotIn", query="delete from Usuario q where q.email = :email and q not in (:lista) "),
	@NamedQuery(name="usuario.deletePorEmail", query="delete from Usuario q where q.email = :email ")
})

public class Usuario implements Serializable, IsSerializable {

	private static final long serialVersionUID = 1095208567310381316L;

	public Usuario() {}
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;

	@Column(unique=true)
	private String email;
	
	private String nome;

	private String senha;
	
	private Boolean emailValidado;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getEmail() {
		email = (email==null)?"":email;
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getNome() {
		nome = (nome==null)?"":nome;
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getSenha() {
		senha = (senha==null)?"":senha;
		return senha;
	}
	public void setSenha(String senha) {
		this.senha = senha;
	}
	public Boolean getEmailValidado() {
		emailValidado = (emailValidado==null)?false:emailValidado;
		return emailValidado;
	}
	public void setEmailValidado(Boolean emailValidado) {
		this.emailValidado = emailValidado;
	}

}
